import { doctypeService } from './doc.type.service';
import { EmrDocTypeInput } from '../InterfaceBll/Idoctype';
import { EmrDocTypeEntity } from '../entities/emr.doc.type.entity';
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
import { Transaction } from 'typeorm';

@Resolver()
export class doctypeResolver {
  constructor(private readonly doctypeService: doctypeService) {}

  @Query(() => [EmrDocTypeEntity], { nullable: true, name: 'findAllText' })
  async findAllText() {
    return await this.doctypeService.findAllText();
  }

  @Query(() => [EmrDocTypeEntity], { nullable: true, name: 'findByName' })
  async findByName(@Args('textname') textname: string) {
    return await this.doctypeService.findByName(textname);
  }

  @Mutation(() => EmrDocTypeEntity)
  async updateOne(@Args('doctype') doctype: EmrDocTypeInput) {
    return await this.doctypeService.updateOne(doctype);
  }

  @Mutation(() => EmrDocTypeEntity)
  async addOne(@Args('doctype') doctype: EmrDocTypeInput) {
    return await this.doctypeService.addOne(doctype);
  }

  @Mutation(() => Boolean)
  async deleteOne(@Args('id') id: string) {
    return await this.doctypeService.deleteOne(id);
  }

  @Mutation(()=>Boolean)
  async transactiontest(): Promise<boolean> {
    return await this.doctypeService.transactiontest();
  }
}
